<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
	<meta charset="utf-8">
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<meta content="width=device-width, minimum-scale=1,initial-scale=1, maximum-scale=1, user-scalable=1" id="viewport" name="viewport" />
	<meta content="yes" name="apple-mobile-web-app-capable" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style" />
	<meta content="telephone=no" name="format-detection" />
	<link type="text/css" rel="stylesheet" href="../../template/css/com/com.css"/>
	<link type="text/css" rel="stylesheet" href="../../template/css/list/style.css"/>
	<link rel="stylesheet" href="../../resource/weuimin.css" />
    <link rel="stylesheet" href="../../resource/jinsuistyle.css" />
	<script src="../../template/js/jquery.js"></script>
    <script type="text/javascript" src="../../script/constants.js"></script>
	<script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
	<script src="../../script/api.js"></script>
    <style type="text/css">

    	body{
    	    background-color: #f1f1f1 !important;
    	}

          .item{
             width：100%;
             height:100px;
             float: :left;
              border-bottom: 1px solid #aaaaaa;
          }
          .item, .text {
              display: -webkit-box;
          }

          .img {
              margin:8px;
              width: 84px;
              height: 84px;

          }
          .text-title{
              margin-top: 5px;
              font-size: 18px;
              height: 25px;
              line-height: 25px;
              color: #000000;
          }

          img {
              width: 100%;
              display: block;
          }

          .text {
              -webkit-box-flex: 1;
              -webkit-box-orient: vertical;
              margin: 0 5px;
          }

          .text-price {
              padding: 2px 0;
          }

          .new-price {
              line-height:22px;
              font-size: 20px;
              color: red;
              font-family: Impact, Arail, sans-serif;
              font-weight: bold;
          }


        .address {
          /*设置超过DIV后隐藏*/
           overflow: hidden;
          text-overflow: ellipsis;
           white-space: nowrap;

          margin-left: 5px;
          line-height: 18px;
        }


        </style>
          <script type="text/javascript">
            var doubliSplierId=1;
            var phone="";
            var hotelId="";
            var name="";
            var starLevel="";
            var address="";
            var picUrl="";

            var cnt=0;
          window.apiready = function() {
            phone = api.pageParam.phone;
            hotelId = api.pageParam.id;
            name = api.pageParam.name;
            starLevel = api.pageParam.starLevel;
            address = api.pageParam.address;
            picUrl = api.pageParam.picUrl;
            // alert(phone);
            // alert(hotelId);
              queryMyHotel();
          }
          function queryMyHotel() {
            var html =  "";
            $("#loadingToast").show();
            var html1 = "";
            html1 += '    <div class="item" style="background-color:#DDDDDD">'+
                  '<div class="text">'+
                    '<div class="text-title">'+name+'<span style="font-size:medium;color:red;padding-left:8px;">'+starLevel+'星</span></div>'+
                  '  <div >地址：'+address+'</div>'+
                  '</div>'+
                    '<div class="img"><img src="'+picUrl+'" style="height:100%;"></div>'+
              '  </div>' ;

                $("#hotelInfo").html(html1);

                var callback = function(ret, err){
                            console.log(JSON.stringify(ret));
                            var data = ret.list;
                              for(i in data){
                                html +=
                                  '<div id="deleteBut'+i+'" style="margin-top:45px;height:55px;width:15%;background-color:#CCCCCC;float:left;'+
                                  'background:url(\'../../image/search_zc/delete.png\');background-size:100%;border-bottom: 1px solid #AAAAAA;display:none" onclick="deleteRoomByID(\''+data[i].RID+'\')"></div>'+
                                '<div id="roomsInfo" class="item" >'+
                                  '<div class="img"><img src="../../image/search_zc/room001.jpg" style="height:100%;"></div>'+
                                  '<div class="text">'+
                                    '<div class="text-title" style="color:#FF9A14">'+data[i].NAME+'</div>'+
                                      '<div class="text-price"><span class="new-price">￥'+data[i].PRICE+'</span></div>'+
                                      '<div class="address">';

                                  if(typeof(data[i].WINDOW)!="undefined")
                                    html+=(data[i].WINDOW+"|");
                                  if(typeof(data[i].BED_TYPE)!="undefined")
                                    html+=(data[i].BED_TYPE+"|");
                                    if(typeof(data[i].BREAKFAST)!="undefined")
                                      html+=(data[i].BREAKFAST+"早|");

                                      html +=
                                      '<div class="address" style="color:ff7c70">已有 '+data[i].AMOUNT+'人设置为我的房间</div>'+
                                       '</div>'+
                                  '</div>'+
                                '</div>';
                                cnt++;
                                    // alert(html);
                              }
                  console.log(html);
                $("#hotelRoomDiv").html(html);
                  $("#loadingToast").hide();
                    }
              var parameter = {"phone":phone,"hotelId":hotelId};
                apiAjax(JSON.stringify(parameter),url.quertRoomsByHotel,callback);
        }
        function editMyHotelRooms() {
          if(cnt>0){
            if($('#deleteBut0').css('display')=='none'){
              $("#edit").html("取消编辑");
              for(var i=0;i<cnt;i++){
                $("#deleteBut"+i).show();
              }
                $("#roomsInfo").css("width","85%");
            }else if($('#deleteBut0').css('display')=='block'){
              $("#edit").html("编辑");
              for(var i=0;i<cnt;i++){
                $("#deleteBut"+i).hide();
              }
                $("#roomsInfo").css("width","100%");
            }

            }
        }

        function deleteRoomByID(roomid) {
          // alert(roomid);
          if(window.confirm('你确定要删除该房间吗？')){

            var callback = function(ret, err){
                        console.log(JSON.stringify(ret));
                        // alert(ret.success);
                        if(ret.success){
                          alert("删除成功");
                          $("#edit").html("编辑");
                          queryMyHotel();
                        }
                        // var data = ret.list;
                        // console.log(html);
                      //   $("#hotelRoomDiv").html(html);
                      // $("#loadingToast").hide();
                      }
                      // alert(roomid);
                var parameter = {"roomid":roomid};
                  apiAjax(JSON.stringify(parameter),url.deleteMyHotelRoom,callback);
                 return true;
              }else{
                 return false;
             }
          }

          </script>
 </head>
 <header id="statusBar">
       <div style="height:50px;background: #298cb4;display: table;width: 100%;">
          <div style="height:50px;margin-top:20px;line-height: 50px;color: #ffffff;background: #1e6887;">
              <div style="width: 26%;margin-left: 4%;font-size: 16px;float: left;" onclick="api.closeWin();">
            返回
            </div>
            <div style="text-align: center;font-weight:bold;width: 40%;font-size: 16px;float: left;">
            我的房间
            </div>
            <div id="edit" style="width: 26%;margin-right: 4%;font-size: 16px;float: left;text-align: right" onclick="editMyHotelRooms()">
            编辑
            </div>
          </div>
       </div>
 </header>
    <div id="hotelInfo">

    </div>
    <div id = "hotelRoomDiv" >
    </div>


<!-- background:url('../../image/search_zc/location1.jpg')
		</div>
	</div> -->
	<!-- 加载动画 -->
	<div id="loadingToast" style="display:none;">
			<div class="weui-mask_transparent"></div>
			<div class="weui-toast">
				<i class="weui-loading weui-icon_toast"></i>
				<p class="weui-toast__content">数据加载中...</p>
			</div>
		</div>
	<!-- 公共底部，必须引用 -->

<!--			<div class="com-footer-area footer" id="js-com-footer" style="width:100%;height: 8%;">
				<img src="../../image/db.png" style="width:100%;"/>
			</div>-->

</body>

</html>
